﻿<Window x:Class="TFSTools.TestManagement.TestCaseReview.TestCaseView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:TFSTools.TestManagement.TestCaseReview"
        Title="{Binding Path=TitleWithId, Mode=OneWay}" Height="600" Width="934" 
        WindowStartupLocation="CenterOwner" 
        Icon="/TFSTools.TestManagement.TestCaseReview;component/Graphics/app.ico" Closing="Window_Closing" Background="WhiteSmoke">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="1" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>
            <Label Grid.Column="0" Grid.Row="0" Content="State" Margin="3" Height="auto"></Label>

            <ComboBox Grid.Row="0" Grid.Column="1" Margin="3" Height="25"
                        ItemsSource="{Binding Path=AvailableStates, Mode=OneWay}"
                        SelectedItem="{Binding Path=State, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEditable="True">
            </ComboBox>

            <Label Grid.Column="2" Grid.Row="0" Content="Reason" Margin="3" Height="auto" VerticalAlignment="Stretch" VerticalContentAlignment="Top"></Label>

            <TextBox Grid.Column="3" Grid.Row="0" Margin="3" Height="25" IsReadOnly="True" Text="{Binding Path=Reason, Mode=OneWay}" Background="WhiteSmoke"
                 Visibility="{Binding Path=IsStateTheSame, Converter={StaticResource BoolToVisConverter} }"></TextBox>
            <ComboBox Grid.Column="3" Grid.Row="0" Margin="3" Height="25" 
                        ItemsSource="{Binding Path=AvailableReasons, Mode=OneWay}"
                        SelectedItem="{Binding Path=Reason, Mode=TwoWay}"
                  Visibility="{Binding Path=IsStateChanged, Converter={StaticResource BoolToVisConverter} }" IsEditable="True">
            </ComboBox>


            <Label Grid.Column="4" Grid.Row="0" Content="Assigned To" Margin="3" Height="auto" VerticalAlignment="Stretch" VerticalContentAlignment="Top"></Label>
            <ComboBox Grid.Row="0" Grid.Column="5" Margin="3" Height="25" IsEditable="True"
                        ItemsSource="{Binding Path=UserNames, Mode=OneWay}"
                        SelectedItem="{Binding Path=AssignedTo, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
            </ComboBox>

            <WrapPanel Grid.Column="0" Grid.ColumnSpan="5" Grid.Row="1" Orientation="Horizontal" Margin="2">
                <Button Margin="6,3,3,3" Width="20" ToolTip="Save" Click="SaveButton_Click">
                    <Image Source="/Graphics/save.png"></Image>
                </Button>

                <Button Margin="3" Width="20" ToolTip="Refresh" Click="RefreshButton_Click" >
                    <Image Source="/Graphics/reset.png"></Image>
                </Button>

                <Border BorderThickness="1,0,0,0" BorderBrush="DarkGray" Margin="3" Width="2">
                    <Rectangle Height="Auto" Width="1" Stroke="DarkGray" Fill="White" StrokeThickness="0" />
                </Border>

                <Button Margin="3" Width="20" ToolTip="Insert Comment" Click="InsertCommentButton_Click">
                    <Image Source="/Graphics/comment.png"></Image>
                </Button>
                <Button Margin="3" Width="20" ToolTip="Clear All Comments" Click="ClearAllCommentsButton_Click">
                    <Image Source="/Graphics/clear.png"></Image>
                </Button>

                <Border BorderThickness="1,0,0,0" BorderBrush="DarkGray" Margin="3" Width="2">
                    <Rectangle Height="Auto" Width="1" Stroke="DarkGray" Fill="White" StrokeThickness="0" />
                </Border>

                <ComboBox Margin="3" Width="200"
                        ItemsSource="{Binding Path=IterationData, Mode=OneWay}"
                        DisplayMemberPath="Name"
                        SelectedValue="{Binding Path=SelectedIteration, Mode=TwoWay}">

                </ComboBox>
                <Button Margin="3" Width="20" ToolTip="Previous Iteration"
                    IsEnabled="{Binding Path=PreviousIterationExists}" Click="PreviousIterationButton_Click">
                    <Image Source="/Graphics/previous.png"></Image>
                </Button>
                <Button Margin="3" Width="20" ToolTip="Next Iteration"
                    IsEnabled="{Binding Path=NextIterationExists}" Click="NextIterationButton_Click">
                    <Image Source="/Graphics/next.png"></Image>
                </Button>
                <CheckBox Margin="3" VerticalAlignment="Center" IsChecked="{Binding Path=IncludeParameterNameInIterationText, Mode=TwoWay}" >Include Parameter Name In Iteration Text</CheckBox>
            </WrapPanel>
        </Grid>
        <ListView x:Name="itemsTestCaseSteps" Grid.Row="2" Margin="0,0" 
                  VerticalContentAlignment="Stretch" 
                  HorizontalContentAlignment="Stretch" 
                  ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                  SelectionMode="Single" SelectionChanged="TestCaseStepsItems_SelectionChanged"
                  ItemsSource="{Binding Path=TestActionList, Mode=OneWay}">
            <ListView.Resources>
                <Style TargetType="{x:Type ListViewItem}">
                    <Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
                    <Style.Resources>
                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/>
                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
                    </Style.Resources>
                </Style>
            </ListView.Resources>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Border BorderBrush="#FF8C8E94" BorderThickness="1,1,1,0" >
                        <Grid Background="{Binding Path=ItemBackground, Mode=OneWay}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="{Binding Path=StepNumberColumnWidth, Mode=OneWay}" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition Height="auto" />
                            </Grid.RowDefinitions>

                            <TextBlock Grid.Column="0" Grid.Row="0" Margin="2,2" Padding="5" Text="{Binding Path=StepNumber, Mode=OneWay}" >
                            </TextBlock>
                            
                            <StackPanel Grid.Column="1" Grid.Row="0" >
                                <TextBlock Margin="2,2" Padding="5,5,5,0" TextWrapping="Wrap" >
                                        <Run Text="{Binding Path=Title1.Text, Mode=OneWay}"></Run>
                                        <Run Text="{Binding Path=TitleParameter1.Text, Mode=OneWay}" Background="{Binding Path=TitleParameter1.ItemBackground, Mode=OneWay}"></Run>
                                        <Run Text="{Binding Path=Title2.Text, Mode=OneWay}"></Run>
                                        <Run Text="{Binding Path=TitleParameter2.Text, Mode=OneWay}" Background="{Binding Path=TitleParameter2.ItemBackground, Mode=OneWay}"></Run>
                                        <Run Text="{Binding Path=Title3.Text, Mode=OneWay}"></Run>
                                </TextBlock>
                                <Border Margin="5" Padding="5" Background="#FFB0D7FB" Visibility="{Binding Path=HasExpectedResult, Converter={StaticResource BoolToVisConverter} }">
                                    <TextBlock TextWrapping="Wrap" Visibility="{Binding Path=HasExpectedResult, Converter={StaticResource BoolToVisConverter} }">
                                            <Run Text="Expected -" FontWeight="Bold"></Run>
                                            <Run Text="{Binding Path=ExpectedResult1.Text, Mode=OneWay}"></Run>
                                            <Run Text="{Binding Path=ExpectedResultParameter1.Text, Mode=OneWay}" Background="{Binding Path=ExpectedResultParameter1.ItemBackground, Mode=OneWay}"></Run>
                                            <Run Text="{Binding Path=ExpectedResult2.Text, Mode=OneWay}"></Run>
                                            <Run Text="{Binding Path=ExpectedResultParameter2.Text, Mode=OneWay}" Background="{Binding Path=ExpectedResultParameter2.ItemBackground, Mode=OneWay}"></Run>
                                            <Run Text="{Binding Path=ExpectedResult3.Text, Mode=OneWay}"></Run>
                                    </TextBlock>
                                </Border>
                            </StackPanel>

                            <Grid Grid.Row="1" Grid.Column="1" Height="{Binding Path=CommentHeight, Mode=OneWay}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Label Grid.Column="0" Grid.Row="0" Content="Comment:" Margin="3" Height="23"></Label>
                                <TextBox Grid.Column="1" Grid.Row="0" Margin="3" Height="22" Text="{Binding Path=Comment, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ></TextBox>
                            </Grid>

                        </Grid>
                    </Border>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
        <!--</ScrollViewer>
        <Border Grid.Row="3" BorderBrush="#FF8C8E94" BorderThickness="1,0,0,0" Height="1" />-->
    </Grid>
</Window>
